#ifndef GAMEWIDGET_H
#define GAMEWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QKeyEvent>
#include <QtGui>

#include "Field.h"
#include "ShopWidget.h"

  // widget, displaying the game
class GameWidget : public QWidget
{
    Q_OBJECT

    public:
        GameWidget( QWidget* parent = 0 )
            :QWidget( parent ), timer( new QTimer )
        {    
            connect( timer, SIGNAL( timeout() ),
                     this, SLOT( update() ) );

            timer->start( INTERVAL );

            scoreboard.setText( "SCORE" );
            stats.setText(      "STATS" );
            QVBoxLayout *layout = new QVBoxLayout;
            layout->addWidget( &scoreboard );
            layout->addWidget( &stats      );
            layout->addWidget( &map        );
            this->setLayout( layout );
            this->setWindowIcon( QIcon( ":/SHIFTZ_LOGO.jpg") );
        }

        ~GameWidget() {
            delete timer;
            delete shop;
        }

          // pauses the game
        void pause();

        Field* getField() const { return field; }
          // also sets shop
        void setField( Field* f );
        QLabel* getScore() { return &scoreboard; }
        QLabel* getStats() { return &stats; }
        QLabel* getMap() { return &map; }
    signals:
        void keyPress( QKeyEvent* event );
    public slots:
        void update() { field->update(); }
    protected:
    protected slots:
        void keyPressEvent( QKeyEvent * event );
        void wheelEvent( QWheelEvent * );
    private:
        static const int INTERVAL = 150;

        Field* field;

        QLabel scoreboard;
        QLabel stats;
        QLabel map;

        QTimer* timer;
        ShopWidget* shop;
};

#endif // GAMEWIDGET_H
